import { defineEventHandler } from "h3";
import auth from "../../../middleware/secure";
const { requireAuth } = auth;
import { UserService } from "../../../services/userService";

export default defineEventHandler(async (event) => {
  const user = await requireAuth(event);

  const { totalPoints, transactions } = await UserService.getUserPoints(user.id);

  return {
    totalPoints,
    transactions: transactions.slice(0, 20), // 最近20条记录
  };
});